package com.minisoft.utils;

import com.minisoft.utils.HttpClientService;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.StandardCharsets;
import java.util.Collections;

public class RestClient {
    public static void main(String[] args) {
        RestTemplate restTemplate = HttpClientService.buildRestTemplate();

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
//        headers.setAcceptCharset(Collections.singletonList(StandardCharsets.UTF_8));

        // 设置中文请求头
        headers.add("createdBy", "微信用户");

        org.springframework.http.HttpEntity<String> entity = new org.springframework.http.HttpEntity<>("{\"activityName\": \"测试\"}", headers);

        String url = "http://activity.paasdev.huafagroup.com/open-api/v1/open/promotion-activity/create";
        String response = restTemplate.postForObject(url, entity, String.class);

        System.out.println(response);
    }
}
